<?php
/**
 * App for managing companies
 * 
 * Template for company searching
 * 
 * @category Abovo
 * 
 * @package Abovo_App_Crm
 * 
 * @subpackage Abovo_App_Crm_Companies
 * 
 * @license http://opensource.org/licenses/gpl-license.php GPL
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 */
?>
<form action="<?php echo $this->action('crm/companies/search') ?>" method="GET">
<fieldset class="inline-form">
    <?php echo $this->formText($this->sform_elements['keywords']) ?>
    <?php echo $this->formSelect($this->sform_elements['key']) ?>
    <?php echo $this->formSubmit($this->sform_elements['process']) ?>
    
    <a href="<?php echo $this->action('crm/companies/add') ?>"><?php echo $this->getText('APP_ACTION_ADD') ?></a>
</fieldset>
</form>

<?php if (count($this->companies) > 0): ?>
<p><?php echo sprintf($this->getText('TEXT_RESULTS'), count($this->companies)) ?></p>
<table class="list">
    <tr>
        <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_NAME') ?></th>
        <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_VAT') ?></th>
        <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_CITY') ?></th>
        <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_DESCR') ?></th>
    </tr>
    <?php foreach ($this->companies as $customer): ?>
        <tr>
            <td><a href="<?php echo $this->action('crm/companies/show/' . $customer->id) ?>">
                <?php echo $customer->name ?></a>
            </td>
            <td><?php echo $this->escape($customer->vat) ?></td>
            <td><?php echo $this->escape($customer->city) ?></td>
            <td><?php echo $this->escape(substr($customer->descr, 0, 50)) ?></td>
        </tr>
    <?php endforeach; ?>
</table>
<?php else: ?>
    <div class="yui-g">
        <div class="yui-u first">
            <?php echo $this->tagCloud($this->citys, 'crm/companies/search?tag=%s') ?>
        </div>
        <div class="yui-u">
            <?php echo $this->tagCloud($this->tags, 'crm/companies/search?tag=%s') ?>
        </div>
    </div>
<?php endif; ?>